<template>
  <el-container class="home-container">
    <!-- 侧边栏 -->
    <el-aside width="200">
      <h1 class="logo" style="height: 60px"></h1>

      <sub-menu></sub-menu>
    </el-aside>
    <el-container>
      <!-- 顶栏 -->
      <el-header>
        <el-row type="flex" class="row-bg" justify="space-between">
          <el-col :span="6">
            <div class="grid-content shouqi" @click="collapse">
              <i :class="menuCollapseIcon"></i>
            </div>
          </el-col>

          <el-col :span="6">
            <div class="grid-content title">
              <h1>千锋rmb管理系统</h1>
            </div>
          </el-col>

          <el-col :span="6">
            <div class="grid-content info">
              <el-avatar :size="40" :src="avatarUrl"></el-avatar>
              <b class="nickname">{{ userInfo.nickname }}</b>
              <a href="javascript:;" class="quit" @click="quit">退出</a>
            </div>
          </el-col>
        </el-row>
      </el-header>
      <!-- 主体 -->
      <el-main>
        <el-breadcrumb separator=">">
          <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
          <el-breadcrumb-item
            v-for="item in breadCrumb"
            :key="item.name"
            :to="{ name: item.name }"
            >{{ item.meta.name }}</el-breadcrumb-item
          >
        </el-breadcrumb>

        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>
<script>
import * as api from "@/api";
import { mapState } from "vuex";
import subMenu from "@/components/Submenu";
export default {
  components: {
    subMenu,
  },
  methods: {
    quit() {
      //退出登入
      //页面跳转到登入页
      this.$router.push("/login");
      //清除localstorage中的qf-token
      localStorage.removeItem("qf-token");
      //因为addRoutes不能删除,所以我们要重新刷新页面
      location.reload();
    },
    collapse() {
      this.$store.commit("SET_MENU_COLLAPSE");
    },
  },
  computed: {
    ...mapState(["userInfo", "menuCollapse", "breadCrumb"]),
    avatarUrl() {
      return this.userInfo.headimgurl
        ? this.userInfo.headimgurl
        : "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png";
    },
    menuCollapseIcon() {
      return this.menuCollapse ? "el-icon-s-unfold" : "el-icon-s-fold";
    },
  },
  data() {
    return {};
  },
  mounted() {},
};
</script>
<style scoped lang="less">
.logo {
  height: 60px;
  background-image: url("../../assets/imgs/logo.png");
  background-size: 80%;
  background-repeat: no-repeat;
  background-position: 50%;
}
.el-header,
.el-footer {
  background: linear-gradient(135deg, #4c67ff, #5635df);
  color: #fff;
  text-align: center;
}
.el-header {
  height: 60px !important;
  // min-height:60px!important;
}

.el-aside {
  background: linear-gradient(135deg, #5635df, #4c67ff);
  color: #333;
  text-align: left;
}

.el-main {
  background-color: #f1efef;
  color: #333;
  text-align: center;
  // line-height: 160px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

//el-row

.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  // padding: 10px 0;
  margin-top: 10px;
}
.el-icon-s-fold,
.el-icon-s-unfold {
  font-size: 40px;
}
.shouqi {
  text-align: left;
  cursor: pointer;
}
.title {
  line-height: 40px;
}
.el-avatar--circle {
  vertical-align: middle;
}
.nickname {
  margin: 0 10px;
}
.quit {
  color: red;
}
</style>
